Clean Code Principles And Patterns by Petri Silen

Clean Code Principles And Patterns by Petri Silen

Author:Petri Silen
Language: eng
Format: epub


Figure 5.55from Message import Message class MessageBuffer: def write_if_buf_not_full(self, message: Message) -> bool: message_was_written = False buffer_is_not_full = len(self.__messages) < self.__max_length if buffer_is_not_full: self.__messages.append(message) message_was_written = True return message_was_written

5.4.5: Extract Named Constant or Enumerated Type

If you encounter a magic number in your code, you should introduce either a named constant or an enumerated type (enum) for that value. In the below example, we are returning two magic numbers, 0 and 1:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.